package com.sql.connection;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class DBConnection {

	public static Connection getConnection() {
        Properties props = new Properties();
        FileInputStream fis = null;
        Connection con = null;
        try {
            fis = new FileInputStream("resources/db.properties");
            props.load(fis);
 
            // load the Driver Class
            Class.forName(props.getProperty("DB_DRIVER_CLASS"));
 
            // create the connection now
            con = DriverManager.getConnection(
            		props.getProperty("DB_URL"),
                    props.getProperty("DB_USERNAME"),
                    props.getProperty("DB_PASSWORD"));
        } catch (IOException e) {
            //TODO:
        	System.out.println("IOException:" + e.getMessage());
        } catch (ClassNotFoundException e) {
        	//TODO:
        	System.out.println("ClassNotFoundException:" + e.getMessage());
        } catch (SQLException e) {
        	//TODO:
        	System.out.println("SQLException" + e.getMessage());
        }
        return con;
    }
}
